package com.med.controller;

import com.med.entity.MedicineDO;
import com.med.service.IMedicineService;
import com.med.vo.MedicineVO;
import com.ruoyi.common.core.domain.R;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/drugs")
@RestController
public class MedicineController {
    @Autowired
    private IMedicineService medicineService;

    @RequestMapping("/add")
    public R<String> addMedicine(@RequestBody MedicineVO medicineVO){
        return medicineService.add(medicineVO);
    }

    @RequestMapping("/update")
    public R<String> updateMedicine(@RequestBody MedicineVO medicineVO){
        return medicineService.updateMedicineByVO(medicineVO);
    }

    @RequestMapping("/delete")
    public R<String> deleteMedicine(@Param("medicineId") Integer medicineId){
        return medicineService.deleteMedicineById(medicineId);
    }

    @RequestMapping("/list")
    public R<List<MedicineDO>> queryAllMedicine(MedicineVO medicineVO){
        return medicineService.queryAllMedicine(medicineVO);
    }

}
